import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class Test {

    public static int area(int left,int right,int height) {
        return (right-left)*height;
    }
    public static List<List<Integer>> threeSum(int[] nums) {
        List<List<Integer>> list=new LinkedList<List<Integer>>();
        Arrays.sort(nums);
        int n=nums.length;
        for(int first=0;first<n;first++) {
            if(nums[first]==nums[first-1]) {
                continue;
            }
            int tmp=-nums[first];
            for(int second=first+1;second<n;second++) {
                if(nums[second]==nums[second-1]) {
                    continue;
                }
                for(int third=second+1;third<n;third++) {
                    if(nums[third]==nums[third-1]) {
                        continue;
                    }
                    if(tmp==nums[second]+nums[third]) {
                        List<Integer> list1=new LinkedList<Integer>();
                        list1.add(nums[first]);
                        list1.add(nums[second]);
                        list1.add(nums[third]);
                        list.add(list1);
                    }
                }
            }
        }
        return list;
    }

    public static int maxArea(int[] height) {

        int left=0;
        int maxArea=0;
        int tmp=0;
        int right=height.length-1;
        while(left<right) {
            if(height[left]<height[right]) {
                maxArea= area(left,right,height[left]);
                if(maxArea>tmp) {
                    tmp=maxArea;
                }
                left++;

            }else {
                maxArea=area(left,right,height[right]);
                if(maxArea>tmp) {
                    tmp=maxArea;
                }
                right--;
            }
        }
        return tmp;

    }
    public static void main3(String[] args) {

    }
    public static void main(String[] args) {
        int[] arr=new int[] {1,8,6,2,5,4,8,3,7};
        int a=maxArea(arr);
        System.out.println(a);


    }

    public static void main1(String[] args) {
        String s="123";
        int a=Integer.valueOf(s);
        System.out.println(a);
        char ch=s.charAt(0);
        System.out.print(ch);

    }
}
